﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace _430GroupProject
{
    //Time range and number of openeings.  Single unit of a schedule.
    [DataContractAttribute]
    public class TimeSlot : SuperClass
    {
        [DataMember]
        public Guid TimeSlotID { get; private set; }

        [DataMember]
        public DateTime StartTime { get; set; }
        [DataMember]
        public DateTime EndTime { get; set; }
        [DataMember]
        public int NumMembers { get; set; }
        [DataMember]
        public List<User> AssignedUsers { get; set; }

        [DataMember]
        public string AssignedUsersList { get; set; }

        public TimeSlot() { }
        public TimeSlot(DateTime start, DateTime End, int numMembers) {
            this.TimeSlotID = Guid.NewGuid();
            StartTime = start;
            EndTime = End;
            NumMembers = numMembers;
            AssignedUsers = new List<User>();
            AssignedUsersList = "";
        }

        public bool addUser(User user) {
            if (AssignedUsers.Count >= NumMembers) {
                return false;
            }
            AssignedUsers.Add(user);
            return true;
        }
    }
}
